package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhAboutMe;
import com.laowang.project.system.service.MyCyhAboutMeService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 关于我们Controller
 * 
 * @author laowang
 * @date 2023-10-30
 */
@Api(tags = "关于我们接口")
@RestController
@RequestMapping("/aboutMe")
public class MyCyhAboutMeController extends BaseController {
    @Autowired
    private MyCyhAboutMeService myCyhAboutMeService;

    @ApiOperation(value = "小程序端 查询关于我们",notes = "")
    @GetMapping("/one")
    public AjaxResult one() {
        MyCyhAboutMe myCyhAboutMe = myCyhAboutMeService.selectMyCyhAboutMeById(1);
        return AjaxResult.success("操作成功",myCyhAboutMe);
    }


    /**
     * 查询关于我们列表
     */
    @ApiOperation(value = "查询关于我们列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhAboutMe myCyhAboutMe) {
        startPage();
        List<MyCyhAboutMe> list = myCyhAboutMeService.selectMyCyhAboutMeList(myCyhAboutMe);
        return getDataTable(list);
    }
    
    /**
     * 导出关于我们列表
     */
    @ApiOperation(value = "导出关于我们列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:export')")
    @Log(title = "关于我们", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhAboutMe myCyhAboutMe) {
        List<MyCyhAboutMe> list = myCyhAboutMeService.selectMyCyhAboutMeList(myCyhAboutMe);
        ExcelUtil<MyCyhAboutMe> util = new ExcelUtil<MyCyhAboutMe>(MyCyhAboutMe.class);
        return util.exportExcel(list, "aboutMe");
    }

    /**
     * 获取关于我们详细信息
     */
    @ApiOperation(value = "获取关于我们详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhAboutMeService.selectMyCyhAboutMeById(id));
    }

    /**
     * 新增关于我们
     */
    @ApiOperation(value = "新增关于我们",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:add')")
    @Log(title = "关于我们", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhAboutMe myCyhAboutMe) {
        return toAjax(myCyhAboutMeService.insertMyCyhAboutMe(myCyhAboutMe));
    }

    /**
     * 修改关于我们
     */
    @ApiOperation(value = "修改关于我们",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:edit')")
    @Log(title = "关于我们", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhAboutMe myCyhAboutMe) {
        return toAjax(myCyhAboutMeService.updateMyCyhAboutMe(myCyhAboutMe));
    }

    /**
     * 删除关于我们
     */
    @ApiOperation(value = "删除关于我们",notes = "")
    @PreAuthorize("@ss.hasPermi('my:aboutMe:remove')")
    @Log(title = "关于我们", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhAboutMeService.deleteMyCyhAboutMeByIds(ids));
    }
}
